<template>
  <div>
    <a-space>
      <a-select
        v-model="values"
        optionFilterProp="label"
        show-search
        placeholder=""
        style="width: 200px"
        @change="handerChange"
        :disabled="isDisabled"
      >
        <a-select-option
          v-for="item in options"
          :key="item.id"
          :value="item.id"
          :label="item.name"
        >{{item.name}}</a-select-option>
      </a-select>
<!--      <a-popconfirm placement="bottomLeft" ok-text="确定" cancel-text="取消" @confirm="confirm">-->
<!--        <template #title>-->
<!--          <div class="table-page-search-wrapper">-->
<!--            <a-form layout="inline" @keyup.enter.native="searchQuery">-->
<!--              <a-row :gutter="24">-->
<!--                <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--                  <a-form-item label="仓库">-->
<!--                    <j-dict-select-tag placeholder="请选择仓库" v-model="queryParam.wareHouseId" dictCode="erp_warehouse,name,id"/>-->
<!--                  </a-form-item>-->
<!--                </a-col>-->
<!--                <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--                  <a-form-item label="库位编号">-->
<!--                    <a-input placeholder="请输入库位编号" v-model="queryParam.code"></a-input>-->
<!--                  </a-form-item>-->
<!--                </a-col>-->
<!--                <template v-if="toggleSearchStatus">-->
<!--                  <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--                    <a-form-item label="库位名称">-->
<!--                      <a-input placeholder="请输入库位名称" v-model="queryParam.name"></a-input>-->
<!--                    </a-form-item>-->
<!--                  </a-col>-->
<!--&lt;!&ndash;                  <a-col :xl="6" :lg="7" :md="8" :sm="24">&ndash;&gt;-->
<!--&lt;!&ndash;                    <a-form-item label="状态">&ndash;&gt;-->
<!--&lt;!&ndash;                      <j-dict-select-tag placeholder="请选择状态" v-model="queryParam.status" dictCode="erp_status"/>&ndash;&gt;-->
<!--&lt;!&ndash;                    </a-form-item>&ndash;&gt;-->
<!--&lt;!&ndash;                  </a-col>&ndash;&gt;-->
<!--                </template>-->
<!--                <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--                            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">-->
<!--                              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>-->
<!--                              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>-->
<!--                              <a @click="handleToggleSearch" style="margin-left: 8px">-->
<!--                                {{ toggleSearchStatus ? '收起' : '展开' }}-->
<!--                                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>-->
<!--                              </a>-->
<!--                            </span>-->
<!--                </a-col>-->
<!--              </a-row>-->
<!--            </a-form>-->
<!--          </div>-->
<!--          &lt;!&ndash; 查询区域-END &ndash;&gt;-->

<!--          &lt;!&ndash; 操作按钮区域 &ndash;&gt;-->
<!--          <div class="table-operator">-->

<!--          </div>-->
<!--          &lt;!&ndash; table区域-begin &ndash;&gt;-->
<!--          <div>-->
<!--            <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">-->
<!--              <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项-->
<!--              <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
<!--            </div>-->
<!--            <a-table-->
<!--              ref="table"-->
<!--              size="middle"-->
<!--              :scroll="{x:true}"-->
<!--              bordered-->
<!--              rowKey="id"-->
<!--              :columns="columns"-->
<!--              :dataSource="dataSource"-->
<!--              :pagination="ipagination"-->
<!--              :loading="loading"-->
<!--              :rowSelection="{selectedRowKeys: selectedRowKeys,onChange: onSelectChange,type: 'radio'}"-->
<!--              class="j-table-force-nowrap"-->
<!--              @change="handleTableChange">-->

<!--            </a-table>-->
<!--          </div>-->
<!--        </template>-->
<!--        <antd-icon type="search-o" />-->
<!--&lt;!&ndash;        <a-button>BL</a-button>&ndash;&gt;-->
<!--      </a-popconfirm>-->
    </a-space>
  </div>
</template>

<script>
import Vue from 'vue'
import { AntDesignOutline, DashboardOutline, TwitterOutline,SearchOutline } from '@ant-design/icons';
import AntdIcon from '@ant-design/icons-vue';
AntdIcon.add(AntDesignOutline, DashboardOutline,SearchOutline);
Vue.use(AntdIcon)


import ErpLocationList from '@/views/modules/location/ErpLocationList'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { mixinDevice } from '@/utils/mixin'
import { getAction } from '@api/manage'
import { ajaxGetDictItems } from '@api/api'

export default {
  name: 'TslMateralSupplier',
  describes: '根据物料选择供应商',
  props:{
    value:{
      type: String,
      required: false,
      default:''
    },
    rowData:{
      type: Object,
      required: false,
    },
    isDisabled:{
      type: Boolean,
      required: false,
      default: false
    },
    materialId: {
      type: String,
      required: false,
    }

    // list: {
    //   type: Array,
    //   required: true
    // },
    // currentStatus: {
    //   type: Number,
    //   default: 0,
    //   required: false
    // }
  },
  mixins:[ mixinDevice],
  components: {
    ErpLocationList
  },
  data() {
    return {
      values: this.value,
      url: {
        list: "/base/erpLocation/list",
        delete: "/base/erpLocation/delete",
        deleteBatch: "/base/erpLocation/deleteBatch",
        exportXlsUrl: "/base/erpLocation/exportXls",
        importExcelUrl: "base/erpLocation/importExcel",
      },
      dictOptions:{},
      superFieldList:[],
      list1:[],
      options:[
        { value: 'jack', label: 'Jack' },
        { value: 'lucy', label: 'Lucy' },
        { value: 'tom', label: 'Tom' },
      ]
    }
  },
  created() {
    this.loadDictData()
  },
  mounted() {
    this.$nextTick(()=>{
      console.log(this.$refs.location)
      // this.$refs.location.showModal();
    })
  },
  computed: {

  },
  methods:{
    loadDictData(){
      let row = {}
      if(this.rowData){
        row = this.rowData.row
        // this.materialId = row.materialId
      }
      getAction('/base/erpSupplier/material/list',{
        materialId: this.materialId || row.materialId
      }).then(res=>{
        if (res.success) {
          this.options = res.result
        }
      })
    },
    confirm(){
      if(this.selectionRows.length > 0){
        const val = this.selectedRowKeys[0];
        this.values = val
        this.callBack(val)
      }
      this.onClearSelected()
    },
    handerChange(value,option){
      this.callBack(value)
    },
    callBack(value){
      getAction('/base/erpSupplier/queryById',{id: value}).then(res=>{
        this.$emit('handlerOk',{
          row: this.rowData?this.rowData.row:'',
          value: value,
          data: res.result
        });
      })
    },
    // getLocationInfo(value){
    //   const { row } = this.rowData
    //   const param = {id: value}
    //   getAction('/base/erpLocation/queryInfoById',param).then(res=>{
    //       if (res.success) {
    //         // 向外传递
    //         this.$emit('handlerOk',{
    //           result: res.result,
    //           row: row
    //         });
    //       }
    //   })
    // },
    add() {
      this.showModal();
    },
    showModal() {
      this.visible = true;
      this.queryParam = { procurementType: this.procurementType }
      this.loadData();
    },
    initDictConfig(){
    },
    getSuperFieldList(){
      let fieldList=[];
      // fieldList.push({type:'string',value:'wareHouseId',text:'仓库',dictCode:"erp_warehouse,name,id"})
      fieldList.push({type:'string',value:'code',text:'库位编号',dictCode:''})
      fieldList.push({type:'string',value:'name',text:'库位名称',dictCode:''})
      fieldList.push({type:'string',value:'status',text:'状态',dictCode:'erp_status'})
      this.superFieldList = fieldList
    },
    handleCancel () {
      this.close()
    },
    handleOk () {
      this.$emit('handlerOk',this.selectionRows[0]);
      this.close();
      // console.log(this.selectionRows[0])
    },
    close() {
      // this.searchReset(false);
      this.queryParam = {}
      this.selectedRowKeys = []
      this.selectionRows = []
      this.visible = false;
    },


  }
}
</script>

<style scoped>
/* 覆盖Dropdown菜单项在悬停时的背景颜色 */
.ant-dropdown-menu-item:hover,
.ant-dropdown-menu-submenu-title:hover {
  background-color: inherit; /* 或者设置为初始背景色 */
}
</style>